<?php //pack11class

class NewValueResponder extends Module {

    public function setup() {
        echo $this->makeAll();
    }

    public function makeAll() {
        $result="0";
        if(!array_key_exists("prop", $_POST)) return "error::prop not defined ".$result;
        if(!array_key_exists("lang", $_POST)) return "error::lang not defined ".$result;

        LanguagesManager::setCurrent($_POST["lang"]);

        $value = new Value;
        $value->propertyID=$_POST["prop"];
        foreach($_POST as $name=>$data) {
            if($name!="prop" && $name!="lang") {
                $value->values[$name]=$data;
            }
        }
        $newID=ValuesManager::createValue($value);

        if(!$newID) return "error::create value error ";

        $value=ValuesManager::getValueByID($newID);
        if(!$value) return "error::not a value ".$result;
        return $newID."::".$value;
    }

}
?>
